let delay = (initial)=>{
    return new Promise(resolve=>{
        setTimeout(()=>{
            resolve(initial);
        },initial)
    })
}

const handle = function* (){
    let value = yield delay(1000);
    console.log('第一个请求成功：',value);

    value = yield delay(2000);
    console.log('第二个请求成功：',value);

    value = yield delay(3000);
    console.log('第三个请求成功：',value);
}

let AsyncFunction = (generator,...params)=>{
    let itor = generator(...params);
    let next = (x)=>{
        let m = itor.next(x);
        if(m.done) return
        if(m.value instanceof Promise) m.value = Promise.resolve(m.value);
        m.value.then(next)
    }
    next();
}
AsyncFunction(handle)